{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "from pandas import Series, DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Sep    96\n",
       "Oct    89\n",
       "Nov    85\n",
       "Dec    78\n",
       "Jan    79\n",
       "Feb    71\n",
       "Mar    72\n",
       "Apr    70\n",
       "May    75\n",
       "Jun    95\n",
       "dtype: int64"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g = np.random.default_rng(0)\n",
    "months = 'Sep Oct Nov Dec Jan Feb Mar Apr May Jun'.split()\n",
    "\n",
    "s = Series(g.integers(70, 101, 10),\n",
    "          index=months)\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Entire year average: 81.0\n"
     ]
    }
   ],
   "source": [
    "print(f'Entire year average: {s.mean()}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Yearly average: 81.0\n",
      "First half average: 85.4\n",
      "Second half average: 76.6\n",
      "Improvement: -8.800000000000011\n"
     ]
    }
   ],
   "source": [
    "first_half_average = s['Sep':'Jan'].mean()\n",
    "second_half_average = s['Feb':'Jun'].mean()\n",
    "\n",
    "print(f'Yearly average: {s.mean()}')\n",
    "\n",
    "print(f'First half average: {first_half_average}')\n",
    "print(f'Second half average: {second_half_average}')\n",
    "\n",
    "print(f'Improvement: {second_half_average - first_half_average}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
